namespace TomatoBreak.DataAccess.Mapping
{
    using NHibernate.Mapping.ByCode;

    using DomainObjects;

    public class ToDoListMap : IClassMap
    {
        public void Map(ModelMapper mapper)
        {
            mapper.Class<ToDoList>(m =>
            {
                m.Id(l => l.Id);

                m.Property(
                    l => l.CreatedAt,
                    c => c.UniqueKey("UQ_ToDoList_UserId_CreatedAt"));

                m.ManyToOne(
                    l => l.User, c =>
                {
                    c.Column("UserId");
                    c.NotNullable(false);
                    c.ForeignKey("FK_ToDoList_User");
                    c.UniqueKey("UQ_ToDoList_UserId_CreatedAt");
                });
            });
        }
    }
}